package com.healthy.education.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.healthy.common.log.annotation.Log;
import com.healthy.common.log.enums.BusinessType;
import com.healthy.common.security.annotation.RequiresPermissions;
import com.healthy.education.domain.Organizers;
import com.healthy.education.service.IOrganizersService;
import com.healthy.common.core.web.controller.BaseController;
import com.healthy.common.core.web.domain.AjaxResult;
import com.healthy.common.core.utils.poi.ExcelUtil;
import com.healthy.common.core.web.page.TableDataInfo;

/**
 * 活动组织者Controller
 * 
 * @author 束伟
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/Organizers")
public class OrganizersController extends BaseController
{
    @Autowired
    private IOrganizersService organizersService;

    /**
     * 查询活动组织者列表
     */
    @RequiresPermissions("education:Organizers:list")
    @GetMapping("/list")
    public TableDataInfo list(Organizers organizers)
    {
        startPage();
        List<Organizers> list = organizersService.selectOrganizersList(organizers);
        return getDataTable(list);
    }

    /**
     * 导出活动组织者列表
     */
    @RequiresPermissions("education:Organizers:export")
    @Log(title = "活动组织者", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Organizers organizers)
    {
        List<Organizers> list = organizersService.selectOrganizersList(organizers);
        ExcelUtil<Organizers> util = new ExcelUtil<Organizers>(Organizers.class);
        util.exportExcel(response, list, "活动组织者数据");
    }

    /**
     * 获取活动组织者详细信息
     */
    @RequiresPermissions("education:Organizers:query")
    @GetMapping(value = "/{organizerId}")
    public AjaxResult getInfo(@PathVariable("organizerId") Long organizerId)
    {
        return success(organizersService.selectOrganizersByOrganizerId(organizerId));
    }

    /**
     * 新增活动组织者
     */
    @RequiresPermissions("education:Organizers:add")
    @Log(title = "活动组织者", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Organizers organizers)
    {
        return toAjax(organizersService.insertOrganizers(organizers));
    }

    /**
     * 修改活动组织者
     */
    @RequiresPermissions("education:Organizers:edit")
    @Log(title = "活动组织者", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Organizers organizers)
    {
        return toAjax(organizersService.updateOrganizers(organizers));
    }

    /**
     * 删除活动组织者
     */
    @RequiresPermissions("education:Organizers:remove")
    @Log(title = "活动组织者", businessType = BusinessType.DELETE)
	@DeleteMapping("/{organizerIds}")
    public AjaxResult remove(@PathVariable Long[] organizerIds)
    {
        return toAjax(organizersService.deleteOrganizersByOrganizerIds(organizerIds));
    }
}
